import xlwings as xw
import numpy

app = xw.App(visible=True)
wb = app.books.open('文件路径')
sheet = wb.sheets('sheet名称')

# 获取表中行数
count = sheet.range('A1').expand('table').shape[0]
num_array = numpy.random.permutation(count) + 1
sheet.range('A1').options(transpose=True).value = num_array  # transpose 填充
wb.save()
wb.close()
app.quit()
